package ch.elektroplan.christian.projectFinder.business.subs;

import java.io.FileNotFoundException;
import java.io.PrintWriter;

import ch.elektroplan.christian.projectFinder.business.ProjectFinder;
import ch.elektroplan.christian.projectFinder.business.interfaces.IConfigFileSaver;

public class ConfigFileSaver implements IConfigFileSaver {
	
	private ConfigfilePF configfilePF;
	private ProjectFinder projectFinder;

	public ConfigFileSaver(ProjectFinder projectFinder, ConfigfilePF configfilePF) {
		this.configfilePF = configfilePF;
		this.projectFinder = projectFinder;

	}

	@Override
	public void saveConfigFile() {
		
		PrintWriter writer = null;

		try {
			writer = new PrintWriter(projectFinder.getConfigFileLoader().getConfigFilePath());

			printData(writer);

			writer.close();

		} catch (FileNotFoundException e) {
		}
	}

	private void printData(PrintWriter writer) {

		writer.println(configfilePF.getxPos());
		writer.println(configfilePF.getyPos());
		for (int i = 0; i < configfilePF.getSearchDirectories().size(); i++) {
			writer.println(configfilePF.getSearchDirectories().get(i));
			
		}
		

	}

	@Override
	public void deleteConfigfile() {
		// TODO Auto-generated method stub

	}

}
